﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TB.BLL;
using System.Web.Script.Serialization;

/// <summary>
/// Summary description for MessagesService
/// </summary>
[WebService(Namespace = "TB.Site.ClientServices")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class MessagesService : System.Web.Services.WebService
{

    public MessagesService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod(EnableSession = true)]
    public string RefillMessages()
    {
        // var msgs = SessionData.MessageHandler.GetAllMessages();
        // msgs = SessionData.MessageHandler.ShufelMessages(msgs);

        var msgs = SessionData.MessageHandler.GetAllMessages();
        msgs = SessionData.MessageHandler.ShufelMessages(msgs);

        return new JavaScriptSerializer().Serialize(msgs);
    }

}
